import React, { PureComponent } from "react"
import { Table } from "antd"
import styles from "./index.less"

class SingleTable extends PureComponent {
  constructor(props) {
    super(props)
    this.state = {}
  }

  handleTableChange = (pagination, filters, sorter) => {
    const { onChange } = this.props
    onChange(pagination, filters, sorter)
  }


  cleanSelectedKeys = () => {
    this.handleRowSelectChange([], [])
  }
  
  totalNum = () => {
    const { data: {  pagination } } = this.props
    return `${pagination.total}  条记录`
  }

  totalNum = () => {
    const { data: {  pagination } } = this.props
    return `${pagination.total}  条记录`
  }

  render() {
    const {
      data: { list, pagination },
      loading,
      columns,
    } = this.props
    const paginationProps = {
      showTotal: this.totalNum,
      showSizeChanger: true,
      showQuickJumper: true,
      pageSize: 20,
      ...pagination,
      pageSizeOptions: ['10'],
    }
    return (
      <div className={styles.standardTable}>
        <Table
          loading={loading}
          rowKey={(record, key) => key}
          dataSource={list}
          columns={columns}
          pagination={paginationProps}
          onChange={this.handleTableChange}
        />
      </div>
    )
  }
}

export default SingleTable
